var pageParamStr = $.url().param('pageParam');
var staffInfo = JSON.parse(pageParamStr);
var view = {
	data: staffInfo
};
var vue_vm = new Vue({
	el: '#vue_vm',
	data: view,
	methods: {
		getImageFullPath: function(iconUrl) {
			return imagePath + '/' + iconUrl;
		}
	}
});

var assignDepartment = function() {
	if($('#department_select').val()=='') {
		$('#department_select').val(staffInfo.departmentId);
	}
}

var assignSubjectRoom = function() {
	if($('#subjectRoom_select').val()=='') {
		$('#subjectRoom_select').val(staffInfo.subjectRoomId);
	}
}

var assignDuty = function() {
	if($('#duty_select').val()=='') {
		$('#duty_select').val(staffInfo.dutyId);
	}
}

var birthdayArray = view.data.birthday.split('-');
var firstEduGraduateTime = view.data.firstEduGraduateTime.split('-');
var maximaEduGraduateTime = view.data.maximaEduGraduateTime.split('-');
var entryTime = view.data.entryTime.split('-');
var contractTime = view.data.contractTime.split('-');

$('#birthYear').val(parseInt(birthdayArray[0]));
$('#birthMonth').val(parseInt(birthdayArray[1]));
$('#birthDay').val(parseInt(birthdayArray[2].substr(0, 2)));

$('#firstEduGraduateYear').val(parseInt(firstEduGraduateTime[0]));
$('#firstEduGraduateMonth').val(parseInt(firstEduGraduateTime[1]));
$('#firstEduGraduateDay').val(parseInt(firstEduGraduateTime[2].substr(0, 2)));

$('#maximaEduGraduateYear').val(parseInt(maximaEduGraduateTime[0]));
$('#maximaEduGraduateMonth').val(parseInt(maximaEduGraduateTime[1]));
$('#maximaEduGraduateDay').val(parseInt(maximaEduGraduateTime[2].substr(0, 2)));

$('#entryYear').val(parseInt(entryTime[0]));
$('#entryMonth').val(parseInt(entryTime[1]));
$('#entryDay').val(parseInt(entryTime[2].substr(0, 2)));

$('#contractYear').val(parseInt(contractTime[0]));
$('#contractMonth').val(parseInt(contractTime[1]));
$('#contractDay').val(parseInt(contractTime[2].substr(0, 2)));

function save() {
	view.data.birthday = $('#birthYear').val() + '-' + $('#birthMonth').val() + '-' + $('#birthDay').val();
	view.data.firstEduGraduateTime = $('#firstEduGraduateYear').val() + '-' + $('#firstEduGraduateMonth').val() + '-' + $('#firstEduGraduateDay').val();
	view.data.maximaEduGraduateTime = $('#maximaEduGraduateYear').val() + '-' + $('#maximaEduGraduateMonth').val() + '-' + $('#maximaEduGraduateDay').val();
	view.data.entryTime = $('#entryYear').val() + '-' + $('#entryMonth').val() + '-' + $('#entryDay').val();
	view.data.contractTime = $('#contractYear').val() + '-' + $('#contractMonth').val() + '-' + $('#contractDay').val();
	
	view.data.managerOfSubjectRoom = (view.data.managerOfSubjectRoom==''? 0: parseInt(view.data.managerOfSubjectRoom));
	view.data.typeOfDuty = (view.data.typeOfDuty==''? 0: parseInt(view.data.typeOfDuty));
	view.data.status = (view.data.status==''? 0: parseInt(view.data.status));
	view.data.accountStatus = (view.data.accountStatus==''? 0: parseInt(view.data.accountStatus));
	view.data.personType = (view.data.personType==''? 0: parseInt(view.data.personType));
	
	if(confirm('确定要修改职工资料吗？')) {
		save_basic(path+'/staffInfo/save', {staffInfo:view.data}, function() {
			alert('保存成功');
		});
	}
}